<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<include file='Common:head'/>
<body>
<script type="text/javascript" src="__ROOT__/Public/Admin/js/jquery-1.7.2.min.js"></script>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>首页</li>
    <li>回收站列表</li>
  </ul>
</div>
<form action="{:U('Article/back')}" method="post">
<div class="rightinfo">
  <div class="tools">
    <ul class="toolbar">
      <a id="backdel"><li><span><img src="__PUBLIC__/Admin/images/t03.png" /></span>撤销</li></a>
      <a id="backdell"><li><span><img src="__PUBLIC__/Admin/images/t03.png" /></span>删除</li></a>
      <li><select name="cid" style="width:150px; height:34px; border:1px solid #CED9DF; line-height:34px;">
            <option value="0">栏目搜索</option>
            <foreach name='cate' item='v'>
            <option value="{$v['id']}">{$v['html']}{$v['name']}</option>
            </foreach>
      </select></li>
      <li><span><input type="text" name="seach"></span></li>
      <li><span><img src="__PUBLIC__/Admin/images/t01.png" /></span><span style="margin-top:7px; font-size:16px;"><input type="submit" value="搜索"></span></li>
    </ul>
  </div>
 
  <table class="tablelist">
    <thead>
      <tr>
        <th><input type="checkbox" id="selall"/></th>
        <th>ID</th>
        <th>标题</th>
        <th>缩图</th>
        <th>图集</th>
        <th>分类</th>
        <th>审核</th>
        <th>时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      <foreach name="article" item="v">
        <tr>
          <td><input type="checkbox" class="selall" name="id[]" value="{$v['id']}"/></td>
          <td>{$v['id']}</td>
          <td>
<?php
    switch($v['xing']){
        case 0:
        	echo '';
       		break; 
        case 1:
        	echo '<a style="color:red;">[推荐]</a>&nbsp;';
        	break;
        case 2:
        	echo '<a style="color:red;">[置顶]</a>&nbsp;';
        	break;
        case 3:
        	echo '<a style="color:red;">[头条]</a>&nbsp;';
        	break;
        case 4:
        	echo '<a style="color:red;">[前排]</a>&nbsp;';
        	break;
        case 5:
        	echo '<a style="color:red;">[火]</a>&nbsp;';
        	break;
    }
?>
          {$v['name']|htmlspecialchars|mb_substr=###,0,20,'utf-8'}

          </td>
          <td>
          	<if condition="$v['tpic'] !== ''"><img src="__ROOT__/{$v['tpic']}" width="50" height="40"><else/> 无图</if>
          </td>
          <td>
          	<if condition="$v['articlepic'] eq 0">无图<else /><a style="color:red;">{$v['articlepic']}</a>&nbsp;张</if>
          </td>
          <td style="font-weight:bold">[ <?php echo $v['category']['name'];?> ]</td>
          <td><if condition="$v['lock'] == 1">无需<else/><a style=" font-weight:bold;">审核</a></if></td>
          <td>{$v['time']|date='Y-m-d H:i',###}</td>
          <td>
          <a href="{:U('Article/backdel',array('id' => $v['id']))}" class="tablelink" onclick="return confirm('确实要撤销吗？')">撤销</a>
          &nbsp;&nbsp;|&nbsp;&nbsp;
          <a href="{:U('Article/backdell',array('id'=>$v['id']))}" class="tablelink" onclick="return confirm('确实要删除吗？')">删除</a>


          </td>
        </tr>
      </foreach>
    </tbody>
  </table>

  <div class="meneame">
    <div class="current"></div>
    {$page} 
  </div>
</div>  
</form>
<script>
/**/
$('#selall').click(function(){
	var chk = $(this).attr('checked');//获取当前的属性
	if(chk){
		$(".selall").attr("checked","checked");//设置当前的属性
	}else{
		$(".selall").removeAttr("checked");//移除当前的属性
	}
});

$(function() {
    var $subBox = $("input[name='id']");
    $subBox.click(function(){
        $(".selall").attr("checked",$subBox.length == $("input[name='id']:checked").length ? true : false);
	
	});
	//ajax批量撤销	
	$("#backdel").click(function(){
		if(confirm("确定撤销勾选内容吗？")){
            var v='';
            var m=$('input[name="id[]"]:checked').length;
            var i=1;
            $('input[name="id[]"]:checked').each(function(){
                if(i==m){
                    v+=$(this).val();
                }else{
                    v+=$(this).val()+",";
                }
                i=i+1;
            });
            if(!v){
                alert('请选择您要撤销的内容！');
            }else{
				//alert(v);//获取到选中的值 1,2,3,4 
				$.ajax({ 
                    type     : "GET", 
                    url      : "{:U('Article/backdel')}", 
					data     : {id:v},
					//async    :  false,//加同步才可以执行
					success  : function(data) {
						if(data == 1){
							alert('批量撤销成功');
							location.reload();	
						}else{
							return false;
						}
                    } 
                }); 
            }
        }else{
            return false;
        }
	});
	//ajax 批量删除
	$("#backdell").click(function(){
		if(confirm("确定删除勾选内容吗？")){
            var v='';
            var m=$('input[name="id[]"]:checked').length;
            var i=1;
            $('input[name="id[]"]:checked').each(function(){
                if(i==m){
                    v+=$(this).val();
                }else{
                    v+=$(this).val()+",";
                }
                i=i+1;
            });
            if(!v){
                alert('请选择您要删除的内容！');
            }else{
				//alert(v);//获取到选中的值 1,2,3,4 
				$.ajax({ 
                    type     : "GET", 
                    url      : "{:U('Article/backdell')}", 
					data     : {id:v},
					//async    :  false,//加同步才可以执行
					success  : function(data) {
						//alert(data);exit;
						if(data == 1){
							alert('批量删除成功');
							location.reload();	
						}else{
							return false;
						}
                    } 
                }); 
            }
        }else{
            return false;
        }
	});
});
</script>
</body>
</html>
